home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.TextField;
-
- public abstract class Spinner extends Panel implements Orientation {
- public final int ORIENTATION_DEFAULT;
- protected int min;
- protected int max;
- protected int current;
- protected String text;
- protected int textWidth;
- protected TextField textField;
- protected int increment = 1;
- private SpinButtonPanel buttons;
- private boolean editable;
- private boolean wrappable;
- private int orientation;
- private boolean textFieldAdded = false;
-
- protected Spinner() {
- this.setWrappable(false);
- this.setMin(0);
- this.setMax(0);
- this.setCurrent(0);
- this.setOrientation(0);
- this.textWidth = -1;
- super.setLayout(new FlowLayout());
- }
-
- public void setEditable(boolean var1) {
- this.editable = var1;
- if (this.textFieldAdded) {
- this.setEditable();
- }
-
- }
-
- public boolean getEditable() {
- return this.editable;
- }
-
- public void setWrappable(boolean var1) {
- this.wrappable = var1;
- }
-
- public boolean getWrappable() {
- return this.wrappable;
- }
-
- public void setMin(int var1) {
- this.min = var1;
- }
-
- public int getMin() {
- return this.min;
- }
-
- public void setMax(int var1) {
- this.max = var1;
- }
-
- public int getMax() {
- return this.max;
- }
-
- public void setCurrent(int var1) {
- this.current = var1;
- this.updateText();
- }
-
- public int getCurrent() {
- return this.current;
- }
-
- public void setOrientation(int var1) {
- this.orientation = var1;
- if (this.buttons != null) {
- ((Container)this).remove(this.buttons);
- }
-
- switch (this.orientation) {
- case 0:
- this.buttons = new VerticalSpinButtonPanel();
- break;
- case 1:
- this.buttons = new HorizontalSpinButtonPanel();
- }
-
- if (this.textFieldAdded) {
- this.setStyle();
- }
-
- }
-
- private void setStyle() {
- ((Container)this).add(this.buttons);
- }
-
- public int getOrientation() {
- return this.orientation;
- }
-
- public void setNotifyWhilePressed(boolean var1) {
- this.buttons.setNotifyWhilePressed(var1);
- }
-
- public boolean getNotifyWhilePressed() {
- return this.buttons.getNotifyWhilePressed();
- }
-
- public void setDelay(int var1) {
- this.buttons.setDelay(var1);
- }
-
- public int getDelay() {
- return this.buttons.getDelay();
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 603:
- this.scrollUp();
- ((Component)this).postEvent(new Event(this, 1001, (Object)null));
- break;
- case 604:
- this.scrollDown();
- ((Component)this).postEvent(new Event(this, 1001, (Object)null));
- }
-
- return super.handleEvent(var1);
- }
-
- private void setEditable() {
- this.textField.setEditable(this.editable);
- }
-
- public void addNotify() {
- super.addNotify();
- if (!this.textFieldAdded) {
- this.textField = new TextField(this.textWidth > 0 ? this.textWidth - 1 : 10);
- this.textField.setBackground(Color.white);
- ((Container)this).add(this.textField);
- this.textFieldAdded = true;
- }
-
- this.setEditable();
- this.setStyle();
- this.updateText();
- }
-
- protected void scrollUp() {
- this.current += this.increment;
- if (this.current > this.max) {
- if (this.wrappable) {
- this.current = this.min;
- } else {
- this.current = this.max;
- }
- }
-
- this.updateText();
- }
-
- protected void scrollDown() {
- this.current -= this.increment;
- if (this.current < this.min) {
- if (this.wrappable) {
- this.current = this.max;
- } else {
- this.current = this.min;
- }
- }
-
- this.updateText();
- }
-
- protected void updateText() {
- if (this.textFieldAdded) {
- this.textField.setText(this.getCurrentText());
- }
-
- }
-
- protected abstract String getCurrentText();
-
- public void setLayout(LayoutManager var1) {
- }
- }
-